//
//  AFHTTPSessionManager+Manager.m
//  CarStor
//
//  Created by 千锋 on 16/1/14.
//  Copyright (c) 2016年 1000phone. All rights reserved.
//

#import "AFHTTPSessionManager+Manager.h"

@implementation AFHTTPSessionManager (Manager)

+ (void)GET:(NSString *)urlStr
 parmaeters:(id) parameters success:(void(^)(NSURLSessionDataTask *task, id responseObject)) success
    failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure
{
    [[self requir] GET:urlStr parameters:parameters success:^(NSURLSessionDataTask * task, id response) {
        success(task,response);
    } failure:^(NSURLSessionDataTask * task, NSError * error) {
        failure(task,error);
    }];
}

+ (void)POST:(NSString *)urlStr parmaeters:(id) parameters
     success:(void(^)(NSURLSessionDataTask *task, id responseObject)) success
     failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure
{
    AFHTTPSessionManager *manager = [self requir];
    [manager POST:urlStr parameters:parameters success:^(NSURLSessionDataTask * task, id response) {
        success(task,response);
    } failure:^(NSURLSessionDataTask * task, NSError * error) {
        failure(task,error);
    }];
}

+ (instancetype)requir
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.requestSerializer.timeoutInterval = 10;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/plain", nil];
    return manager;
}

@end
